package com.Algorithm.HUAWEI.one20211020;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2021/10/21/14:25
 * @Description: 每行的每个数，是恰好是它上面的数，左上角数到右上角的数，3个数之和
 * @Target:
 */
public class 杨辉三角的变形 {
    //            1
    //         1  1  1
    //      1  2  3  2  1
    //   1  3  6  7  6  3  1
    //1  4  10 16 19 16 10  4  1

// 1  3  5  7  9  一行的个数:::1+2*(n-1) 9-5=4


    public static void main(String[] args) {
        // 定义一个二维数组

        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            run(scanner.nextInt());
        }



    }



    public static void run(int n){

        int flag = -1;
        int[][] arr = getArray(n);
        int len = 1+2*(n-1); // 5
        for (int j = 0; j < len; j++) {
            if (arr[n-1][j]%2==0){
                flag = j+1;
                break;
            }else{
                if (flag==-1){
                    flag=-1;
                }
            }
        }
        System.out.println(flag);
    }





    public static int[][] getArray(int n){
        int len = 1+2*(n-1);  // 列长


        int arr[][] = new int[n][len];


        for (int i = 0; i < n; i++) {
            for (int j = 0; j < len; j++) {
                if(j==len-n-i||j==len-n+i){
                    arr[i][j]=1;
                }else if (j>len-n-i&&j<len-n+i){
                    if ((j-1)<0){
                        arr[i][j] = arr[i-1][j]+arr[i-1][j+1];
                    }else if ((j+1)>len){
                        arr[i][j] = arr[i-1][j-1]+arr[i-1][j];
                    }else {
                        arr[i][j] = arr[i-1][j-1]+arr[i-1][j]+arr[i-1][j+1];
                    }
                }

            }
        }

        return arr;
    }



}
